import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { CustomerVO, CustomerForm, CustomerQuery } from '@/api/billiards/customer/types';

/**
 * 查询顾客管理列表
 * @param query
 * @returns {*}
 */

export const listCustomer = (query?: CustomerQuery): AxiosPromise<CustomerVO[]> => {
  return request({
    url: '/customer/all',
    method: 'get',
    params: query
  });
};

/**
 * 查询顾客管理详细
 * @param id
 */
export const getCustomer = (id: string | number): AxiosPromise<CustomerVO> => {
  return request({
    url: '/system/customer/' + id,
    method: 'get'
  });
};

/**
 * 新增顾客管理
 * @param data
 */
export const addCustomer = (data: CustomerForm) => {
  return request({
    url: '/customer/addCustomer',
    method: 'post',
    data: data
  });
};

/**
 * 修改顾客管理
 * @param data
 */
export const updateCustomer = (data: CustomerForm) => {
  return request({
    url: '/system/customer',
    method: 'put',
    data: data
  });
};

/**
 * 删除顾客管理
 * @param id
 */
export const delCustomer = (id: string | number | Array<string | number>) => {
  return request({
    url: '/customer/del',
    data: { id: id },
    method: 'delete'
  });
};

export const activeCustomer = (phone: string | number | Array<string | number>) => {
  return request({
    url: '/customer/active',
    params: { phone: phone },
    method: 'get'
  });
};

export const resetPassword = (data: CustomerForm) => {
  return request({
    url: '/customer/restPassword',
    data: data,
    method: 'post'
  });
};
